<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:p="http://primefaces.org/ui">
   
   <ui:composition template="/admin.xhtml">
      <ui:define name="page.title">
         Administração - Cadastros - Usuário
      </ui:define>
      
      <ui:define name="admin.content">
         <p:spacer height="10" />
      
         <h:form id="crud">
            <p:panel id="panel" toggleable="true" toggleSpeed="100" 
               toggleTitle="#{msg['user.register.title']}"
               header="#{msg['user.register.title']}">
               
               <p:messages />
               
               <h:panelGrid columns="3">
                  <h:outputText value="#{msg['user.register.label.username']}" />
                  <p:spacer width="10" />
                  <p:inputText id="username" value="#{user.current.username}" />
                  
                  <h:outputText value="#{msg['user.register.label.password']}" />
                  <p:spacer width="10" />
                  <p:password id="password" value="#{user.current.password}"
                     feedback="true" inline="true"
                     promptLabel="#{msg['user.password.prompt']}"
                     weakLabel="#{msg['user.password.weak']}"
                     goodLabel="#{msg['user.password.normal']}"
                     strongLabel="#{msg['user.password.strong']}" />
                     
                  <h:outputText value="#{msg['user.register.label.type']}" />
                  <p:spacer width="10" />
                  <p:selectOneRadio id="usertype" layout="block"
                     value="#{user.current.type}">
                     <f:selectItems value="#{user.userTypes}" />
                  </p:selectOneRadio>                  
               </h:panelGrid>
               
               <p:spacer height="15" />
               <br/>
               
               <p:commandButton id="save" 
                  value="#{msg['crud.save']}"
                  async="true" update="crud list" action="#{user.save}" />
                  
               <p:commandButton id="cancel"
                  value="#{msg['crud.cancel']}"
                  async="true" update="crud" immediate="true" />
            </p:panel>
            
            <br />
            <p:spacer height="15" />
            <br />
            
            <p:panel id="list" toggleable="true" toggleSpeed="100" 
               toggleTitle="#{msg['user.list.title']}"
               header="#{msg['user.list.title']}">
               
               <ui:include src="/user-list.xhtml" />
            </p:panel>
         </h:form>
      </ui:define>
   </ui:composition>
</html>
